package com.ruoyi.web.controller.fireman;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fireman.domain.TImagePosition;
import com.ruoyi.fireman.service.ITImagePositionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图片位置Controller
 * 
 * @author ruoyi
 * @date 2021-08-30
 */
@Controller
@RequestMapping("/fireman/position")
public class TImagePositionController extends BaseController
{
    private String prefix = "fireman/position";

    @Autowired
    private ITImagePositionService tImagePositionService;

    @RequiresPermissions("fireman:position:view")
    @GetMapping()
    public String position()
    {
        return prefix + "/position";
    }

    /**
     * 查询图片位置列表
     */
    @RequiresPermissions("fireman:position:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TImagePosition tImagePosition)
    {
        startPage();
        List<TImagePosition> list = tImagePositionService.selectTImagePositionList(tImagePosition);
        return getDataTable(list);
    }

    /**
     * 导出图片位置列表
     */
    @RequiresPermissions("fireman:position:export")
    @Log(title = "图片位置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TImagePosition tImagePosition)
    {
        List<TImagePosition> list = tImagePositionService.selectTImagePositionList(tImagePosition);
        ExcelUtil<TImagePosition> util = new ExcelUtil<TImagePosition>(TImagePosition.class);
        return util.exportExcel(list, "图片位置数据");
    }

    /**
     * 新增图片位置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存图片位置
     */
    @RequiresPermissions("fireman:position:add")
    @Log(title = "图片位置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TImagePosition tImagePosition)
    {
        return toAjax(tImagePositionService.insertTImagePosition(tImagePosition));
    }

    /**
     * 修改图片位置
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TImagePosition tImagePosition = tImagePositionService.selectTImagePositionById(id);
        mmap.put("tImagePosition", tImagePosition);
        return prefix + "/edit";
    }

    /**
     * 修改保存图片位置
     */
    @RequiresPermissions("fireman:position:edit")
    @Log(title = "图片位置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TImagePosition tImagePosition)
    {
        return toAjax(tImagePositionService.updateTImagePosition(tImagePosition));
    }

    /**
     * 删除图片位置
     */
    @RequiresPermissions("fireman:position:remove")
    @Log(title = "图片位置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tImagePositionService.deleteTImagePositionByIds(ids));
    }
}
